
fid=fopen('datapic7.txt', 'r');
subplot(2,2,1);
sp2=textscan(fid, '%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f','delimiter', ' ', 'headerLines', 0);
plot(sp2{1}, sp2{4},'LineWidth',1)

%axis([0 4*1024 -0.5 0.5])
xlabel('Time')
title('C: Transmitted field Ey')
Y2 = fft(sp2{4});

dt=8.053399e-02;
ndt=1024*32;
w0=0.05;

dw=2*pi/ndt/dt;
wmax=pi/dt;
subplot(2,2,2);
w=0:dw:wmax-dw;
length(w/w0)
length(log10((abs(Y2(1:length(Y2)/2)))  ))
plot(w/w0,log10((abs(Y2(1:length(Y2)/2)))  ))

%Pyy = Y.* conj(Y);
%plot(s{1},Pyy)
xlim([0 20])
title('C: Spectrum of the tansmitted field')
xlabel('frequency in harmonics')

fclose(fid);



subplot(2,2,3);
plot(sp2{1}, sp2{3},'r','LineWidth',1)

%axis([0 4*1024 -0.5 0.5])
xlabel('Time')
title('C: Reflected field Ey')

Y1 = fft(sp2{3});

w0=5.700000e-02;

dw=2*pi/ndt/dt;
wmax=pi/dt;
subplot(2,2,4);
w=0:dw:wmax-dw;
plot(w/w0,log10((abs(Y1(1:length(Y1)/2)))), 'r')


xlim([0 20])
title('C: Spectrum of the reflected field')
xlabel('frequency in harmonics')


figure
subplot(2,2,1);
plot(sp2{1}, sp2{6},'r','LineWidth',1)

xlabel('Time')
title('C: Exleft')

subplot(2,2,3);
plot(sp2{1}, sp2{7},'r','LineWidth',1)

xlabel('Time')
title('C: Exright')

subplot(2,2,2);
plot(sp2{1}, sp2{8},'g','LineWidth',1)

xlabel('Time')
title('C: Ro0left')

subplot(2,2,4);
plot(sp2{1}, sp2{8},'g','LineWidth',1)

xlabel('Time')
title('C: Ro0right')

figure
plot(sp2{1}, sp2{5},'r','LineWidth',1)

xlabel('Time')
title('C: Ey incidente')


%fid3=fopen('datapic4.txt', 'r');

%pos=textscan(fid3, '%f\t%f');
%plot(pos{1}, pos{2},'Linestyle','none','Marker','.','MarkerSize',1);
%figure
%plot(pos{1}, pos{2});

%axis([0 4*1024 -0.5 0.5])
%xlabel('Time')
%ylabel('Position')
%title('Trayectories of the particles in time')


%fclose(fid3);